<include file="public/header" />
<body>
<div class="layui-fluid">
  <div class="layui-row">
    <form class="layui-form">
      <div class="layui-form-item">
        <label for="username" class="layui-form-label">
          <span class="x-red">*</span>余额
        </label>
        <div class="layui-input-inline">
          <input type="number" disabled  value="{$info.money}"
                 autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">
          <span class="x-red">*</span>增加金额
        </label>
        <div class="layui-input-inline">
          <input type="number"  name="money"  required="" lay-verify="required"
                 autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
          <label class="layui-form-label">取向</label>
          <div class="layui-input-block">
            <input type="radio" name="case" checked value="add" title="增加" >
            <input type="radio" name="case" value="del" title="减少" >
          </div>
        </div>

        <div class="layui-form-item" >
          <div class="layui-input-block">
            <input type="hidden" name="id" value="{$info.id}">
            <button type="button"  class="layui-btn" lay-submit=""  lay-filter="addEdit">保存</button>
          </div>
        </div>
    </form>
  </div>
</div>
<script>

  layui.use(['form', 'layedit', 'laydate','jquery','upload'], function(){
    var form = layui.form
            ,layer = layui.layer
            , $ = layui.jquery
            , upload = layui.upload
            ,laydate = layui.laydate
            ,inputTags = layui.inputTags
    var layedit = layui.layedit;
    //拖拽上传

    function generateRandomString(length, type) {
      let characters; // 将变量声明移到函数顶部

      if (type === 'str') {
        characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
      } else {
        characters = '0123456789';
      }

      let result = '';
      for (let i = 0; i < length; i++) {
        const randomIndex = Math.floor(Math.random() * characters.length);
        result += characters[randomIndex];
      }

      return result;
    }
    // 使用 jQuery 监听按钮点击事件
    $('#changeValueBtn').on('click', function(){

      const appId = generateRandomString(10,'number');
      const Secret = generateRandomString(32,'str'); // Adjust length as needed
      $('#appid').val(appId);
      $('#secret').val(Secret);
    });

    // 使用 jQuery 监听按钮点击事件
    $('#changeKey').on('click', function(){

      const key = generateRandomString(16,'str'); // Adjust length as needed
      $('#key').val(key);

    });


    form.on('submit(addEdit)', function(data){
      $.post($('form').attr('action'),data.field,function(data){
        if(data.code == 200){
          layer.msg(data.msg);
          setTimeout(function () {
            window.history.back();
          },2000)
          xadmin.close();
          xadmin.father_reload();
        }else {
          layer.msg(data.msg);
        }
      });
      return false;
    });
  });

</script>
</body>

</html>
